package cn.codeinn.service2.service.impl;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.codeinn.generator.service.impl.ServiceImpl;
import cn.codeinn.generator.util.Page;

import cn.codeinn.service2.mapper.DictMapper;
import cn.codeinn.service2.entity.Dict;
import cn.codeinn.service2.service.DictService;

@Service("dictService")
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {

    @Override
    public Page<Dict> queryPage(Page<Dict> page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<Dict> list = mapper.select(page.getCondition(Dict.class));
        page.setPage(new PageInfo<>(list));
        return page;
    }

    @Override
    @Cacheable(value = "dictCache", key = "'SELECTBYID-'+#id")
    public Dict selectById(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Dict> selectByCloth(Integer clothid) {
        return mapper.selectByCloth(clothid);
    }
}
